<?php
	class JaraGeneralException extends Exception { }
	class JaraDatabaseException extends Exception {
		protected $mysqlCode = 0;
		protected $mysqlMessage = "";
		protected $mysqlQuery = "";
		protected $mysqlStage = 0; // 0 = undefined, 1 = connection, 2 = query
		
		public function __construct($mysqlStage = 1, $mysqlCode = 0, $mysqlMessage = "", $mysqlQuery = "") {
			$this->mysqlCode = $mysqlCode;
			$this->mysqlStage = $mysqlStage;
			$this->mysqlCode = $mysqlCode;
			$this->mysqlMessage = $mysqlMessage;
			$this->mysqlQuery = $mysqlQuery;
			parent::__construct($mysqlMessage, 103800);
		}

		public function getSqlCode() {
			return $this->mysqlCode;
		}
		
		public function getSqlMsg() {
			return $this->mysqlMessage;
		}
		
		public function getSqlQuery() {
			return $this->mysqlQuery;
		}
		
		public function getSqlStage() {
			return $this->mysqlStage;
		}
		
		public function __toString() {
			return "Jara database ".(($this->mysqlStage == 1) ? "connection" : "query")." error: ".$this->mysqlMessage;
		}
	}
?>